home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 2.iso / tomcon / tomcon4.c < prev   
C/C++ Source or Header  |  1991-10-19  |  5KB  |  233 lines

  1. /*
  2.     TOMCON4.C  by Y.Kurihara (Nif PDC01620)
  3.             サブルーチン
  4. */
  5.  
  6. #include <string.h>
  7. #include <jctype.h>
  8. #include <dos.h>
  9. #include <machine.h>
  10. #include "tomcon.h"
  11.  
  12. int save_page;
  13. int save_plane;
  14.  
  15. void cur( int m )
  16. {
  17.     unsigned off;
  18.  
  19.     if( fl_cur == m )  return;
  20.     fl_cur = m;
  21.  
  22.     save_page  = inp( PORTpage );
  23.     save_plane = inp( PORTplane );
  24.     outp( PORTplane,15 );
  25.  
  26.     if( ly + y0 < Y1page ) {
  27.         outp( PORTpage,0x00 );
  28.         off = ( ly + y0 ) * ( 16 * 128 );
  29.     } else {
  30.         outp( PORTpage,0x10 );
  31.         off = ( ly + y0 - Y1page ) * ( 16 * 128 );
  32.     }
  33.     off += ( 15 * 128 ) + ( lx + x0 );
  34.     *VRAM( off ) = ~ *VRAM( off );
  35.  
  36.     outp( PORTpage,  save_page );
  37.     outp( PORTplane, save_plane );
  38.     return;
  39. }
  40.  
  41. void putank( int code )            /* 半角文字の表示 */
  42. {
  43.     unsigned off,add;
  44.     int n;
  45.  
  46.     save_page  = inp( PORTpage );
  47.     save_plane = inp( PORTplane );
  48.     outp( PORTplane,15 );
  49.     outp( PORTank,1 );
  50.  
  51.     if( ly + y0 < Y1page ) {
  52.         outp( PORTpage,0x00 );
  53.         off = ( ly + y0 ) * ( 16 * 128 ) + ( lx + x0 );
  54.     } else {
  55.         outp( PORTpage,0x10 );
  56.         off = ( ly + y0 - Y1page ) * ( 16 * 128 ) + ( lx + x0 );
  57.     }
  58.     add = code * 16;
  59.  
  60.     for( n = 16; --n >= 0;  ) {
  61.         *VRAM( off ) = *ANKCG( add++ ) ^ reverse;
  62.         off += 128;
  63.     }
  64.  
  65.     outp( PORTank,0 );
  66.     outp( PORTpage,  save_page );
  67.     outp( PORTplane, save_plane );
  68.     return;
  69. }
  70.  
  71. void putkan( unsigned code )        /* 全角文字の表示 */
  72. {
  73.     unsigned off;
  74.     int n;
  75.  
  76.     save_page  = inp( PORTpage );
  77.     save_plane = inp( PORTplane );
  78.     outp( PORTplane,15 );
  79.     outp( PORTank,1 );
  80.  
  81.     if( ly + y0 < Y1page ) {
  82.         outp( PORTpage,0x00 );
  83.         off = ( ly + y0 ) * ( 16 * 128 ) + ( lx + x0 );
  84.     } else {
  85.         outp( PORTpage,0x10 );
  86.         off = ( ly + y0 - Y1page ) * ( 16 * 128 ) + ( lx + x0 );
  87.     }
  88.  
  89.     outp( PORTkch,code >> 8 );
  90.     outp( PORTkcl,code );
  91.  
  92.     for( n = 16; --n >= 0;  ) {
  93.         *VRAM( off )     = inp( PORTkfl ) ^ reverse;
  94.         *VRAM( off + 1 ) = inp( PORTkfr ) ^ reverse;
  95.         off += 128;
  96.     }
  97.  
  98.     outp( PORTank,0 );
  99.     outp( PORTpage,  save_page );
  100.     outp( PORTplane, save_plane );
  101.     return;
  102. }
  103.  
  104. void clr( int y1,int y2 )        /* 画面クリア */
  105. {
  106.     unsigned off;
  107.     int x,y,n;
  108.  
  109.     save_page  = inp( PORTpage );
  110.     save_plane = inp( PORTplane );
  111.     outp( PORTplane,15 );
  112.     outp( PORTank,1 );
  113.  
  114.     if( y1 < Y1page ) {
  115.         outp( PORTpage, 0x00 );
  116.         off = y1 * 16 * 128 + x0;
  117.     } else {
  118.         outp( PORTpage, 0x10 );
  119.         off = ( y1 - Y1page ) * 16 * 128 + x0;
  120.     }
  121.     for( y = y1; y <= y2; y++ ) {
  122.         if( y == Y1page ) {
  123.             outp( PORTpage, 0x10 );
  124.             off = off - Y1page * 16 * 128;
  125.         }
  126.         for( n = 0; n <= 15; n++ ) {
  127.             for( x = xl; --x >= 0; )  *VRAM( off + x ) = 0xff;
  128.             off = off + 128;
  129.         }
  130.     }
  131.  
  132.     outp( PORTank,0 );
  133.     outp( PORTpage,  save_page );
  134.     outp( PORTplane, save_plane );
  135. }
  136.  
  137. void roll( int y1,int y2 )        /* スクロール */
  138. {
  139.     unsigned off;
  140.     int x,y,n;
  141.     static char buff[ 128 ];
  142.  
  143.     save_page  = inp( PORTpage );
  144.     save_plane = inp( PORTplane );
  145.     outp( PORTplane,15 );
  146.     outp( PORTank,1 );
  147.  
  148.     if( y1 < Y1page ) {
  149.         outp( PORTpage, 0x00 );
  150.         off = y1 * 16 * 128 + x0;
  151.     } else {
  152.         outp( PORTpage, 0x10 );
  153.         off = ( y1 - Y1page ) * 16 * 128 + x0;
  154.     }
  155.     for( y = y1; y < y2; y++ ) {
  156.         if( y == Y1page - 1 ) {
  157.             for( n = 0; n <= 15; n++ ) {
  158.                 outp( PORTpage, 0x10 );
  159.                 movedata( 0xc000,n * 128 + x0,
  160.                     FP_SEG(buff),FP_OFF(buff),xl );
  161.                 outp( PORTpage, 0x00 );
  162.                 movedata( FP_SEG(buff),FP_OFF(buff),
  163.                     0xc000,off,xl );
  164.                 off = off + 128;
  165.             }
  166.             outp( PORTpage, 0x10 );
  167.             off = off - Y1page * 16 * 128;
  168.         } else {
  169.             for( n = 0; n <= 15; n++ ) {
  170.                 movedata( 0xc000,off + 128 *16,0xc000,off,xl );
  171.                 off += 128;
  172.             }
  173.         }
  174.     }
  175.     for( n = 0; n <= 15; n++ ) {
  176.         for( x = xl; --x >= 0; )  *VRAM( off + x ) = 0xff;
  177.         off = off + 128;
  178.     }
  179.  
  180.     outp( PORTank,0 );
  181.     outp( PORTpage,  save_page );
  182.     outp( PORTplane, save_plane );
  183. }
  184.  
  185. void roll2( int y1,int y2 )        /* スクロール */
  186. {
  187.     unsigned off,off2;
  188.     int x,y,n;
  189.     static char buff[ 128 ];
  190.  
  191.     save_page  = inp( PORTpage );
  192.     save_plane = inp( PORTplane );
  193.     outp( PORTplane,15 );
  194.     outp( PORTank,1 );
  195.  
  196.     if( y2 < Y1page ) {
  197.         outp( PORTpage, 0x00 );
  198.         off = y2 * 16 * 128 + x0;
  199.     } else {
  200.         outp( PORTpage, 0x10 );
  201.         off = ( y2 - Y1page ) * 16 * 128 + x0;
  202.     }
  203.     for( y = y2; y > y1; y-- ) {
  204.         if( y == Y1page ) {
  205.             off2 = off;
  206.             off = ( Y1page - 1 ) * 16 * 128 + x0;
  207.             for( n = 0; n <= 15; n++ ) {
  208.                 outp( PORTpage, 0x00 );
  209.                 movedata( 0xc000,n * 128 + off,
  210.                     FP_SEG(buff),FP_OFF(buff),xl );
  211.                 outp( PORTpage, 0x10 );
  212.                 movedata( FP_SEG(buff),FP_OFF(buff),
  213.                     0xc000,n * 128 + off2,xl );
  214.             }
  215.             outp( PORTpage, 0x00 );
  216.         } else {
  217.             for( n = 0; n <= 15; n++ ) {
  218.                 off -= 128;
  219.                 movedata( 0xc000,off,0xc000,off +128 *16,xl );
  220.             }
  221.         }
  222.     }
  223.     for( n = 0; n <= 15; n++ ) {
  224.         for( x = xl; --x >= 0; )  *VRAM( off + x ) = 0xff;
  225.         off += 128;
  226.     }
  227.  
  228.     outp( PORTank,0 );
  229.     outp( PORTpage,  save_page );
  230.     outp( PORTplane, save_plane );
  231. }
  232.  
  233.